package cubelabs.nexus.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import cubelabs.nexus.entity.OpenTokArchive;

@Repository("openTokArchiveDAO")
public class OpenTokArchiveDAO extends BaseDAO<OpenTokArchive, Long> {

	public OpenTokArchive findByEventId(Long eventId){
		Criteria crit = getSession().createCriteria(getPersistentClass());
		crit.add(Restrictions.eq("event.id", eventId));
		OpenTokArchive openTokArchive = (OpenTokArchive) crit.uniqueResult();
		return openTokArchive;
	}
	
	public List<OpenTokArchive> findAllByStatus(String status){
		Criteria crit = getSession().createCriteria(getPersistentClass());
		crit.add(Restrictions.eq("status", status));
		List<OpenTokArchive> openTokArchiveList = (List<OpenTokArchive>) crit.list();
		return openTokArchiveList;
	}

	public OpenTokArchive findByArchiveId(String archiveId) {
		Criteria crit = getSession().createCriteria(getPersistentClass());
		crit.add(Restrictions.eq("archiveId", archiveId));
		OpenTokArchive openTokArchive = (OpenTokArchive) crit.uniqueResult();
		return openTokArchive;
	}
}
